package models

import (
	"time"

	"github.com/go-xorm/xorm"
)

//Sync 同步数据库
func Sync(e *xorm.Engine) error {
	var err error
	err = e.Sync2(&UserBean{}, &CharacterBean{},
		&UserLoginBean{}, &CharacterLoginBean{}, &FDSerialBean{}, &Announcement{},
		&CardInfo{}, &AccountBean{}, &MoneyBean{}, &UserInfoBean{}, &TradeRecordBean{},
		&TradeCodeBean{},
	)
	if err != nil {
		return err
	}
	return nil
}

//BaseBean 基本的Bean 用于自增长的id
type BaseBean struct {
	ID        int64
	Version   int       `xorm:"version"`
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
}

type UserBaseBean struct {
	UserId    int64
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
}
